#####################################
#            Time plugin            #
#       Made by loliconshik3        #
#####################################

from plugins.plugin import Plugin
from plugins.item import Item

from datetime import date, datetime

class Time(Plugin):

    def __init__(self, config=None) -> None:
        super().__init__(config)
        self.name = "Time"
        self.save_config()

    def get_current_date(self):
        """
        Return current date in readable format
        """
        today = date.today()
        return {
            "day"   : today.day,
            "month" : today.month,
            "year"  : today.year
        }

    def get_current_time(self):
        """
        Return current time in readable format
        """
        now = datetime.now()
        return {
            "hour"      : now.hour,
            "minute"    : now.minute,
            "second"    : now.second
        }

    def get_current_datetime(self):
        """
        Return current date & time
        """
        now = datetime.now()
        return {
            "hour"      : now.hour,
            "minute"    : now.minute,
            "second"    : now.second,
            "day"       : now.day,
            "month"     : now.month,
            "year"      : now.year
        }

    def get_items(self) -> list:
        """
        Return list of plugin actions with options:
        Item(name_of_item, item_action, is_input_required).convert_to_json()
        name_of_item        - Readable name for users
        item_action         - Name of method in this class for action
        is_input_required   - Is user need to send some input? 
        """
        return [ 
            Item("Get current date",        'get_current_date',     False).to_json(),
            Item("Get current time",        'get_current_time',     False).to_json(),
            Item("Get current datetime",    'get_current_datetime', False).to_json() 
        ]

    def save_config(self) -> None:
        """
        Save options to main config
        """
        pass



